/**
 * 
 */
package br.edu.unoesc.smschool.model;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;

import org.apache.commons.lang.builder.CompareToBuilder;
import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

/**
 * @author Luiz
 * data: 15-08-2011
 */
@Entity
public class Disciplina extends GenericModel implements Comparable<Disciplina> {
	
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Id
	@GeneratedValue(strategy = GenerationType.AUTO)
	private Long codigo;
	@Column(nullable = false)
	private String nome;
	
	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}
	
	@Override
	public Long getCodigo() {
		return codigo;
	}
	
	@Override
	public void setCodigo(Long codigo) {
		this.codigo = codigo;
	}

	@Override
	public boolean equals(Object obj) {
		Disciplina outro = (Disciplina) obj;
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		Disciplina that = (Disciplina) obj;
		return new EqualsBuilder().append(this.getNome(), outro.getNome())
				.isEquals();
	}

	@Override
	public int hashCode() {
		int obj1 = 0;
		int obj2 = 0;
		if (obj1 == obj2)
			return obj1;
		if (obj2 == obj1)
			return obj2;
		return new HashCodeBuilder().append(this.getNome()).hashCode();
	}

	@Override
	public String toString() {
		return new ToStringBuilder(this, ToStringStyle.MULTI_LINE_STYLE)
				.append("Nome", this.getNome()).toString();
	}

	public int compareTo(Disciplina o) {
		return new CompareToBuilder().append(this.getNome(), o.getNome())
				.toComparison();
	}

}
